#VERSION 1
# Example of using the makefile script 

# traget : Source file of the project
#	Generate command

#hello : main.cpp factorial.cpp printhello.cpp
#	g++ -o hello main.cpp printhello.cpp factorial.cpp



#VERSION 2 
# CC = g++  #

# TARGET = hello

# SRC = main.o printhello.o factorial.o

# $(TARGET) : $(SRC)
# 	$(CC) -o $(TARGET) $(SRC)

# main.o : main.cpp
# 	$(CC) -c main.cpp
# printhello.o : printhello.cpp
# 	$(CC) -c printhello.cpp
# factorial.o : factorial.cpp
# 	$(CC) -c factorial.cpp


#VERSION 3

# $@ : indicates the project name
# $^ : Represents all source files of the project
# $< : Represents the first source in the project


# CC = g++
# TARGET = hello 
# OBJ = main.o printhello.o factorial.o

# CFLAGES = -c -Wall 

# $(TARGET) : $(OBJ)
# 	$(CC) -o $@ $(OBJ)

# %.o: %.cpp
# 	$(CC) $(CFLAGES) $< -o $@

# .PHONY: clean
# clean :
# 	rm -f *.o $(TARGET)

#VERSION 4
# The suffix * is the file format you want 
# wildcard  :	Read all source files 
#
#	format	:	SRC = $(wildcard *.*)	
#
# patsubst 	:	Replace source file
#				
#				name = $(patsubst %.*, %.* , $(name))
#	format  :	OBJ = $(patsubst %.cpp, %.o, $(SRC))
#


CC = g++
TARGET = hello
SRC = $(wildcard *.cpp)
OBJ = $(patsubst %.cpp, %.o ,$(SRC))

CFLAGES = -c -Wall

$(TARGET): $(OBJ)
	$(CC) -o $@ $^
%.o:%.cpp
	$(CC) $(CFLAGES) $< -o $@

#.PHONY: clean
# clean :
# 	rm -f *.o $(TARGET)


